I've got a database with postgis installed, but it doesn't work anymore:
# SELECT PostGIS_full_version();
ERROR: could not access file "$libdir/postgis-2.5": No such file or directory
CONTEXT: SQL statement "SELECT public.postgis_lib_version()"
PL/pgSQL function postgis_full_version() line 26 at SQL statement
I found other answers which suggested running ALTER EXTENSION postgis UPDATE;, so I did, but it has no effect:
my_db=# ALTER EXTENSION postgis UPDATE;
NOTICE: version "2.5.4" of extension "postgis" is already installed
ALTER EXTENSION
my_db=#
my_db=# SELECT PostGIS_full_version();
ERROR: could not access file "$libdir/postgis-2.5": No such file or directory
CONTEXT: SQL statement "SELECT public.postgis_lib_version()"
PL/pgSQL function postgis_full_version() line 26 at SQL statement
Does anybody have any idea on how to solve this?
(I'm on Ubuntu 20.04 with Posrgresql version 12.3. and I recently upgraded from Ubuntu 19.10 to 20.04, which I *think is when this started to be a problem)
[EDIT]
I searched in apt, and found this package which I didn't have installed yet: postgresql-12-postgis-2.5. So after installing that (sudo apt install postgresql-12-postgis-2.5) I restarted postgresql (sudo service postgresql restart) and tried again, but I still get the same error.
It happened the same to me, after upgrading to Ubuntu 20.04.
Usually a postgresql major upgrade do not replace the previous version, because the dabatase has to be dumped and restored. The new version is installed alongside the old one, and at the new server is assigned a different port. Is up to the user to migrate the old database to the new version.
In my case, the upgrade, for some reason, removed the postgis-2.5 library in the previous postgresql version, leaving a broken postgis installation in the old database (and no installation in the new one, of course.)
It's easy to be confused and connect to the wrong server; at least, I was easly confused and so received the same error message even after having installed postgis for the new postgresql version. I discovered the problem checking pg_lsclusters and understanding which server was listening on which port.